import 'package:flutter/material.dart';

/// @author zdl
/// date 2021/05/26 14:24
/// email zdl328465042@163.com
/// description 扩展color
extension ExtensionColor on Color {

  Color get _noAlpha => Color.fromARGB(0, red, green, blue);

  String get _hex => _noAlpha.value.toRadixString(16);

  /// 解析颜色为字符串，忽略透明度
  String get toHex =>  '#${_hex.padLeft(6, '0')}';

  /// 解析颜色为字符串，忽略透明度
  String get getColorStr => '#${_hex.padLeft(6, '0')}';

  TextStyle toStyle(double fontSize, {bool bold = false}) => TextStyle(
    color: this,
    fontSize: fontSize,
    fontWeight: bold ? FontWeight.bold : FontWeight.normal,
  );
}